import ajax from '@/api/apiConfig.js'
import store from '@/store/store'
import {
  updateInspectionData
} from '@/api/offlineWork'

// 巡检列表
export const getTaskList = data => {
  if (!store.state.isOffline) {
    data.result = 1
  }
  return ajax.get('examine/getTaskList', data)
}

// 领取任务
export const activeObtaining = data => {
  return ajax.get('examine/activeObtaining', data)
}

// 邀请他人一起巡检
export const inviteOthers = data => {
  return ajax.get('examine/inviteOthers', data)
}

// 开始巡检-巡检点位
export const beginExamine = data => {
  return ajax.get('examine/beginExamine', data)
}

// 任务状态统计
export const getTaskCount = data => {
  return ajax.get('examine/getTaskCount', data)
}

// 获取任务详情
export const getExamineTaskDeatil = data => {
  if (!store.state.isOffline) {
    data.result = 1
  }
  return ajax.get('examine/getExamineTaskDeatil', data)
}

// 点位巡检内容（扫一扫）
export const getExaminePointContentList = data => {
  return ajax.get('examine/getExaminePointContentList', data)
}

// 提交点位巡检结果
export const commitPointResult = data => {
  if (store.state.isOffline) {
    updateInspectionData(data);
    return new Promise((resolve) => {
      resolve({
        status: 200
      })
    })
  }
  return ajax.post('examine/commitPointResult', data)
}

// 查看任务点位巡检结果
export const getTaskPointResult = data => {
  return ajax.get('examine/getTaskPointResult', data)
}

// 根据二维码获取点位状态
export const getPointNowStatus = data => {
  return ajax.get('examine/getPointNowStatus', data)
}

// 更新巡检点位图片
export const updatePointPic = data => {
  return ajax.get('examine/updatePointPic', data)
}

// 统计-数量
export const getExamineTaskListCount = data => {
  return ajax.get('examine/getExamineTaskListCount', data)
}

// 统计-团队-单位完成度
export const getExamineTaskOrgOrder = data => {
  return ajax.get('examine/getExamineTaskOrgOrder', data)
}

// 统计-团队-人员信息
export const getExamineTaskPeopleCount = data => {
  return ajax.get('examine/getExamineTaskPeopleCount', data)
}

// 统计-清单-日数据统计
export const getExamineTaskDailyStats = data => {
  return ajax.get('examine/getExamineTaskDailyStats', data)
}

// 统计-团队-任务数据统计
export const getExamineTaskStats = data => {
  return ajax.get('examine/getExamineTaskStats', data)
}

// 统计-任务列表
export const getExamineTaskListByPage = data => {
  return ajax.get('examine/getExamineTaskListByPage', data)
}

// 统计-不合格点位任务列表
export const getExamineTaskListByIds = data => {
  return ajax.get('examine/getExamineTaskListByIds', data)
}

// 统计-不合格点位-点位巡检结果
export const getPointResultStats = data => {
  return ajax.get('examine/getPointResultStats', data)
}

// 统计-不合格点位-点位列表
export const getExaminePointListByPage = data => {
  return ajax.get('examine/getExaminePointListByPage', data)
}
